// @Bind @dtRouting.onInsert
!function(self, arg) {

var loginUsername = "${loginUsername}";

var routing = arg.entity;

routing.set("creatorUid", loginUsername);


}


//@Bind view.onReady
!function(self, arg) {
partUid = '${request.getParameter("partUid")}';
var dsRouting = view.id("dsRouting");
dsRouting.set("parameter", {partUid: partUid});
dsRouting.flush();

}

// @Bind #updateActionSave.beforeExecute
!function(self, arg) {
var dsRouting = view.id("dsRouting")

var routing = dsRouting.getData("#");

var isEffective = routing.get("isEffective");

var isDefault = routing.get("isDefault");

if (isEffective == false&&isDefault==true) {
	dorado.MessageBox.alert("请先选择有效性");
   Routing.set("isDefault",false);
   isDefault.set("readOnly",true);
}else{
   routing.set("partUid",partUid);
}

}

// @Bind #dgRouting.beforeCellValueEdit
!function(self, arg) {
//编辑之前
var column = arg.column;
var dsRouting = view.id("dsRouting");

var routing = dsRouting.getData("#");

if (column.get("name") == "isDefault"){
	if (!routing.get("isEffective")){
		dorado.MessageBox.alert("请先选择有效性!");
		routing.set("isDefault", false);
	}
}

}

// @Bind #dgRouting.onCellValueEdit
!function(self, arg) {
//编辑之后
var column = arg.column;
var dsRouting = view.id("dsRouting");
var routing = dsRouting.getData("#");
if (column.get("name") == "isEffective"){
	if (!routing.get("isEffective") && routing.get("isDefault")){
		routing.set("isDefault", false);
	}
}
}

// @Bind #dpRoutingType.beforeExecute
!function(self,arg,dsTypesData) {
dsTypesData.set("parameter", {typeName:"routing_type"});
dsTypesData.flush();
}

// @Bind #dpRoutingType.onValueSelect
!function(self, arg) {
var dsRouting = view.id("dsRouting");

var routing = dsRouting.getData("#");

var dsTypesData = view.id("dsTypesData");

var typeData = dsTypesData.getData("#");

routing.set("routingType",typeData.get("typeId"));

routing.set("routingTypeDesc",typeData.get("idDescription"));


}

// @Bind #dpProductPhase.beforeExecute
!function(self,arg,dsTypesData) {
dsTypesData.set("parameter", {typeName:"PRODUCT_PHASE"});
dsTypesData.flush();
}

// @Bind #dpProductPhase.onValueSelect
!function(self, arg) {
var dsRouting = view.id("dsRouting");

var routing = dsRouting.getData("#");

var dsTypesData = view.id("dsTypesData");

var typeData = dsTypesData.getData("#");

routing.set("productPhase",typeData.get("typeId"));

routing.set("productPhaseDesc",typeData.get("idDescription"));


}

// @Bind #deptTree.onDataRowClick
!function(self,arg,dsRouting) {
var dropDown = dorado.widget.DropDown.findDropDown(self);
var node = self.get("currentNode");
var routing = dsRouting.getData("#");

routing.set("masterShopUid", node.get("data").get("deptUid"));
routing.set("masterShop.deptName", node.get("data").get("deptName"));

view.id("masterShop").refreshData();

dropDown.close();

}


